# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import annotations

from typing import MutableMapping, MutableSequence

from google.protobuf import timestamp_pb2  # type: ignore
import proto  # type: ignore

from google.cloud.apihub_v1.types import common_fields

__protobuf__ = proto.module(
    package="google.cloud.apihub.v1",
    manifest={
        "CollectionType",
        "CollectApiDataRequest",
        "ApiData",
        "ApiMetadataList",
        "APIMetadata",
        "VersionMetadata",
        "SpecMetadata",
        "DeploymentMetadata",
        "CollectApiDataResponse",
    },
)


class CollectionType(proto.Enum):
    r"""The type of the collect request.

    Values:
        COLLECTION_TYPE_UNSPECIFIED (0):
            The default value. This value is used if the
            collection type is omitted.
        COLLECTION_TYPE_UPSERT (1):
            The collection type is upsert. This should be
            used when an API is created or updated at the
            source.
        COLLECTION_TYPE_DELETE (2):
            The collection type is delete. This should be
            used when an API is deleted at the source.
    """
    COLLECTION_TYPE_UNSPECIFIED = 0
    COLLECTION_TYPE_UPSERT = 1
    COLLECTION_TYPE_DELETE = 2


class CollectApiDataRequest(proto.Message):
    r"""The CollectApiData method's request.

    Attributes:
        location (str):
            Required. The regional location of the API hub instance and
            its resources. Format:
            ``projects/{project}/locations/{location}``
        collection_type (google.cloud.apihub_v1.types.CollectionType):
            Required. The type of collection. Applies to all entries in
            [api_data][google.cloud.apihub.v1.CollectApiDataRequest.api_data].
        plugin_instance (str):
            Required. The plugin instance collecting the API data.
            Format:
            ``projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}``.
        action_id (str):
            Required. The action ID to be used for
            collecting the API data. This should map to one
            of the action IDs specified in action configs in
            the plugin.
        api_data (google.cloud.apihub_v1.types.ApiData):
            Required. The API data to be collected.
    """

    location: str = proto.Field(
        proto.STRING,
        number=1,
    )
    collection_type: "CollectionType" = proto.Field(
        proto.ENUM,
        number=2,
        enum="CollectionType",
    )
    plugin_instance: str = proto.Field(
        proto.STRING,
        number=3,
    )
    action_id: str = proto.Field(
        proto.STRING,
        number=4,
    )
    api_data: "ApiData" = proto.Field(
        proto.MESSAGE,
        number=5,
        message="ApiData",
    )


class ApiData(proto.Message):
    r"""The API data to be collected.

    .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

    Attributes:
        api_metadata_list (google.cloud.apihub_v1.types.ApiMetadataList):
            Optional. The list of API metadata.

            This field is a member of `oneof`_ ``Data``.
    """

    api_metadata_list: "ApiMetadataList" = proto.Field(
        proto.MESSAGE,
        number=1,
        oneof="Data",
        message="ApiMetadataList",
    )


class ApiMetadataList(proto.Message):
    r"""The message to hold repeated API metadata.

    Attributes:
        api_metadata (MutableSequence[google.cloud.apihub_v1.types.APIMetadata]):
            Required. The list of API metadata.
    """

    api_metadata: MutableSequence["APIMetadata"] = proto.RepeatedField(
        proto.MESSAGE,
        number=1,
        message="APIMetadata",
    )


class APIMetadata(proto.Message):
    r"""The API metadata.

    Attributes:
        api (google.cloud.apihub_v1.types.Api):
            Required. The API resource to be pushed to
            Hub's collect layer. The ID of the API resource
            will be generated by Hub to ensure uniqueness
            across all APIs across systems.
        versions (MutableSequence[google.cloud.apihub_v1.types.VersionMetadata]):
            Optional. The list of versions present in an
            API resource.
        original_id (str):
            Optional. The unique identifier of the API in
            the system where it was originally created.
        original_create_time (google.protobuf.timestamp_pb2.Timestamp):
            Optional. Timestamp indicating when the API
            was created at the source.
        original_update_time (google.protobuf.timestamp_pb2.Timestamp):
            Required. Timestamp indicating when the API
            was last updated at the source.
    """

    api: common_fields.Api = proto.Field(
        proto.MESSAGE,
        number=1,
        message=common_fields.Api,
    )
    versions: MutableSequence["VersionMetadata"] = proto.RepeatedField(
        proto.MESSAGE,
        number=2,
        message="VersionMetadata",
    )
    original_id: str = proto.Field(
        proto.STRING,
        number=3,
    )
    original_create_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=4,
        message=timestamp_pb2.Timestamp,
    )
    original_update_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=5,
        message=timestamp_pb2.Timestamp,
    )


class VersionMetadata(proto.Message):
    r"""The metadata associated with a version of the API resource.

    Attributes:
        version (google.cloud.apihub_v1.types.Version):
            Required. Represents a version of the API
            resource in API hub. The ID of the version will
            be generated by Hub.
        specs (MutableSequence[google.cloud.apihub_v1.types.SpecMetadata]):
            Optional. The specs associated with this
            version. Note that an API version can be
            associated with multiple specs.
        deployments (MutableSequence[google.cloud.apihub_v1.types.DeploymentMetadata]):
            Optional. The deployments linked to this API
            version. Note: A particular API version could be
            deployed to multiple deployments (for dev
            deployment, UAT deployment, etc.)
        original_id (str):
            Optional. The unique identifier of the
            version in the system where it was originally
            created.
        original_create_time (google.protobuf.timestamp_pb2.Timestamp):
            Optional. Timestamp indicating when the
            version was created at the source.
        original_update_time (google.protobuf.timestamp_pb2.Timestamp):
            Required. Timestamp indicating when the
            version was last updated at the source.
    """

    version: common_fields.Version = proto.Field(
        proto.MESSAGE,
        number=1,
        message=common_fields.Version,
    )
    specs: MutableSequence["SpecMetadata"] = proto.RepeatedField(
        proto.MESSAGE,
        number=2,
        message="SpecMetadata",
    )
    deployments: MutableSequence["DeploymentMetadata"] = proto.RepeatedField(
        proto.MESSAGE,
        number=4,
        message="DeploymentMetadata",
    )
    original_id: str = proto.Field(
        proto.STRING,
        number=5,
    )
    original_create_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=6,
        message=timestamp_pb2.Timestamp,
    )
    original_update_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=7,
        message=timestamp_pb2.Timestamp,
    )


class SpecMetadata(proto.Message):
    r"""The metadata associated with a spec of the API version.

    Attributes:
        spec (google.cloud.apihub_v1.types.Spec):
            Required. The spec resource to be pushed to
            Hub's collect layer. The ID of the spec will be
            generated by Hub.
        original_id (str):
            Optional. The unique identifier of the spec
            in the system where it was originally created.
        original_create_time (google.protobuf.timestamp_pb2.Timestamp):
            Optional. Timestamp indicating when the spec
            was created at the source.
        original_update_time (google.protobuf.timestamp_pb2.Timestamp):
            Required. Timestamp indicating when the spec
            was last updated at the source.
    """

    spec: common_fields.Spec = proto.Field(
        proto.MESSAGE,
        number=1,
        message=common_fields.Spec,
    )
    original_id: str = proto.Field(
        proto.STRING,
        number=2,
    )
    original_create_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=3,
        message=timestamp_pb2.Timestamp,
    )
    original_update_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=4,
        message=timestamp_pb2.Timestamp,
    )


class DeploymentMetadata(proto.Message):
    r"""The metadata associated with a deployment.

    Attributes:
        deployment (google.cloud.apihub_v1.types.Deployment):
            Required. The deployment resource to be
            pushed to Hub's collect layer. The ID of the
            deployment will be generated by Hub.
        original_id (str):
            Optional. The unique identifier of the
            deployment in the system where it was originally
            created.
        original_create_time (google.protobuf.timestamp_pb2.Timestamp):
            Optional. Timestamp indicating when the
            deployment was created at the source.
        original_update_time (google.protobuf.timestamp_pb2.Timestamp):
            Required. Timestamp indicating when the
            deployment was last updated at the source.
    """

    deployment: common_fields.Deployment = proto.Field(
        proto.MESSAGE,
        number=1,
        message=common_fields.Deployment,
    )
    original_id: str = proto.Field(
        proto.STRING,
        number=2,
    )
    original_create_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=3,
        message=timestamp_pb2.Timestamp,
    )
    original_update_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=4,
        message=timestamp_pb2.Timestamp,
    )


class CollectApiDataResponse(proto.Message):
    r"""The CollectApiData method's response."""


__all__ = tuple(sorted(__protobuf__.manifest))
